<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="author" content="得闲技术 Team">
    <meta name="copyright" content="得闲技术">
    <title>添加${modelMap.entityComment!} - Powered By 得闲技术</title>
    [#include "/admin/main/resources/list.ftl"/]
</head>
<body class="admin secondary">
<main>
    <div class="container-fluid">
        <form id="saveOrUpdateForm" class="ajax-form form-horizontal" action="save" method="post">
            <div class="panel panel-default">
                <div class="panel-heading">添加${modelMap.entityComment!}</div>
                <div class="panel-body padding-5">

                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a href="#basic" data-toggle="tab">基本信息</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="basic" class="tab-pane active">

                            <#list modelMap.fields as field>
                            <#if field.bool>
                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label">设置:</label>
                                <div class="col-xs-9 col-sm-4">
                                    <div class="checkbox checkbox-inline">
                                        <input name="_${field.name}" type="hidden" value="false">
                                        <input id="${field.name!}" name="${field.name!}" type="checkbox" value="true">
                                        <label for="${field.name!}">${field.comment!}</label>
                                    </div>
                                </div>
                            </div>
                            <#else>
                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label <#if !field.nullable>item-required</#if>" for="${field.name!}">${field.comment!}:</label>
                                <div class="col-xs-9 col-sm-4">
                                    <input id="${field.name!}" name="${field.name!}" class="form-control" type="text" <#if field.length &gt; 0>maxlength="${field.length}"</#if><#if !field.nullable>required="required"</#if> />
                        </div>
                    </div>
                </#if>
            </#list>
    </div>
    </div>
    </div>
    <div class="panel-footer">
        <div class="row">
            <div class="col-xs-9 col-sm-10 col-xs-offset-3 col-sm-offset-2">
                <button class="btn btn-primary" type="submit">确 定</button>
                <button class="btn btn-default" type="button" data-action="back">返 回</button>
            </div>
        </div>
    </div>
    </div>
    </form>
    </div>
</main>
<script>
    $().ready(function () {

        var $saveOrUpdateForm = $("#saveOrUpdateForm");

        // 表单验证
        $saveOrUpdateForm.validate({
            rules: {},
            messages: {},
            submitHandler: function (form) {
                $(form).ajaxSubmit();
            }
        });
    });
</script>
</body>
</html>
